﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using SPM.DTL;
using SPM.BL;

namespace SPM
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //FormView1.PageIndex = -1;
        }

        protected void btSalvar_Click(object sender, EventArgs e)
        {
            BeneficiarioDto dto = new BeneficiarioDto();
            BeneficiarioBo bo = new BeneficiarioBo();

            dto.Id = -1;
            //dto.Nome = txtNome.Text;
            //dto.DtNascimento = txtDtNascimento.Text;
            //dto.Idade = Int32.Parse(txtIdade.Text);
            //dto.Responsavel = txtResponsavel.Text;
            //dto.Endereco = txtEndereco.Text;
            //dto.Bairro = txtBairro.Text;

            if (bo.Save(dto) != -1)
            {
                //if (dto.Id == -1)
                //    lblResult.Text = "Beneficario Cadastrado com Sucesso!!";
                //else
                //    lblResult.Text = "Beneficario Atualizado com Sucesso!!";
                //limparCampos();
            }
            else
            {
                //lblResult.Text = "Erro ao salvar os dados!!";
            }

        }

        private void limparCampos()
        {
            //string blank = "";
            //txtNome.Text = blank;
            //txtResponsavel.Text = blank;
            //txtIdade.Text = blank;
            //txtEndereco.Text = blank;
            //txtDtNascimento.Text = blank;
            //txtBairro.Text = blank;
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int count = GridView1.PageIndex * GridView1.PagerSettings.PageButtonCount;
            FormView1.PageIndex = count + GridView1.SelectedIndex; 
            FormView1.ChangeMode(FormViewMode.Edit);
        }

        protected void FormView1_PageIndexChanging(object sender, FormViewPageEventArgs e)
        {

        }

    }
}
